<layout name="../Common/Master/master" />
<include file="../Common/Master/left" />
<script src="__PUBLIC__/Home/js/area.js"></script>
<div class="orderright">
	<div class="orderlist">
		<h2>添加地址</h2>
		<form action="" method="post" onsubmit="return addaddr(this)">
			<div class="address">
				<div class="addressname"><span>收货人姓名:</span><input value="{$olddata['postname']}" name="postname" type="text" placeholder="请输入收货人姓名" required="required" /></div>
				<div class="addressname">
					<span>收货人地址:</span>
					<select name="useraddr[]" id="area1"></select>
					<select name="useraddr[]" id="area2"></select>
					<select name="useraddr[]" id="area3"></select><br/>
					<textarea name="useraddr[]" style="margin-top: 10px"  cols="37" rows="5" placeholder="详细街道">{$olddata['useraddr'][3]}</textarea>
				</div>
				<script>
					$(function () {
						area.init('area');
						//选中效果
					area.selected("{$olddata['useraddr'][0]}","{$olddata['useraddr'][1]}","{$olddata['useraddr'][2]}");
					})
				</script>
				<div class="addressname"><span>收货人邮编:</span><input value="{$olddata['postcode']}" name="postcode" type="text" placeholder="收货人邮编" required="required" /></div>
				<div class="addressname"><span>收货人手机号:</span><input value="{$olddata['phone']}" name="phone" type="text" placeholder="收货人手机号" required="required" /></div>
				<div class="addbtn"><input type="submit" id="" name="" value="保存" /></div>
			</div>
		</form>

	</div>
</div>
	</div>
<script>
   function addaddr(that){
        var data=$(that).serialize();
	   $.post("{:U('home/userinfo/addaddr')}",data,function(res){
            if(res.valid){
				location.href="{:U('home/userinfo/addr')}";
			}else{
				layer.alert(res.msg, {icon: 6});
			}
	   });
	   return false;
   }
</script>


